package cn.jsj.dispose;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 结案处理类
 * @author LI
 *
 */
 public class SettleCase extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 	// 调试信息
		 	cn.jsj.utils.SysLogger.PrintInfo("结案处理类！！！！！！！");

		 	//获得案件合同号
			String contractId=request.getParameter("settleCaseId").trim();
			//获取承办律师姓名
			String underLawyer=request.getParameter("settleUnderLawyer").trim();
			//获取卷宗押金修改情况
			int archiveDeposit=Integer.parseInt(request.getParameter("settleDeposit").trim());
			//获取签名信息
			String signInfo=request.getParameter("settlepassWord").trim();

			//调试信息
			cn.jsj.utils.SysLogger.PrintInfo("contractID---------->"+contractId+" "+underLawyer+"  "+archiveDeposit+"   "+signInfo);

			//输出流
			java.io.PrintWriter out=response.getWriter();

			//验证签名是否正确
			cn.jsj.dao.TblLawyerDAO tld=new cn.jsj.dao.TblLawyerDAO();
			//1.有效 0 无效
			int validate=tld.signedVerify(underLawyer, signInfo);

			//如果签名无效
			if(validate==0){
				out.println("{message:'签名无效！'}");
				out.flush();
				out.close();
				return;
			}

			//结案
			cn.jsj.dao.TblCaseInfoDAO tcid=new cn.jsj.dao.TblCaseInfoDAO();
			int settleResult=tcid.settleCaseInfo(contractId,archiveDeposit);


			//如果结案成功
			if(settleResult==1){
				out.println("{message:'结案成功！'}");
			}
			else{
				out.println("{message:'结案失败！'}");
			}
			out.flush();
			out.close();
	}

}